import Vue from 'vue'
import VueRouter from 'vue-router'
import InitView from '../views/InitView.vue'
// import HomeView from '../views/HomeView.vue'
import SelectClassic from '../views/SelectClassic.vue'
import InvoiceListView from '../views/InvoiceListView.vue'
import ErrorView from '../views/ErrorView.vue'
import ManualInputView from '../views/ManualInputView.vue'
import ManualShowView from '../views/ManualShowView.vue'
import ManualShowEditView from '../views/ManualShowEditView.vue'
import LoginView from '../views/LoginView.vue'
import InvoiceInfoView from '../views/InvoiceInfoView.vue'

import store from '../store'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'login',
    component: LoginView,
    meta: {
      title: '登录',
    },
  },
  {
    path: '/init',
    name: 'init',
    component: InitView,
    meta: {
      title: '发票录入',
    },
  },
  {
    path: '/selectclassic',
    name: 'selectclassic',
    component: SelectClassic,
    meta: {
      title: '类型选择',
    },
  },
  // {
  //   path: '/home',
  //   name: 'home',
  //   component: HomeView,
  //   meta: {
  //     title: 'Home Page',
  //   },
  // },
  {
    path: '/invoicelist',
    name: 'invoicelist',
    component: InvoiceListView,
    meta: {
      title: '发票夹',
    },
  },
  {
    path: '/error',
    name: 'error',
    component: ErrorView,
    meta: {
      title: '查验失败',
    },
  },
  {
    path: '/manualinput',
    name: 'manualinput',
    component: ManualInputView,
    meta: {
      title: '输入信息',
    },
  },
  {
    path: '/manualshow',
    name: 'manualshow',
    component: ManualShowView,
    meta: {
      title: '输入信息',
    },
  },
  {
    path: '/manualshowedit',
    name: 'manualshowedit',
    component: ManualShowEditView,
    meta: {
      title: '输入信息',
    },
  },
  {
    path: '/invoiceInfo',
    name: 'invoiceinfo',
    component: InvoiceInfoView,
    meta: {
      title: '发票详情',
    },
  },
  
]
const router = new VueRouter({
  routes
})

router.afterEach((to) => {
  // console.log(to.path,from);
  // 是否显示底部菜单
  let arr = ["/init","/invoicelist"]
  store.commit('setNavShow', arr.includes(to.path));
});

// 在这里可以获取当前的路由信息
// router.beforeEach((to, from, next) => {
//   if(localStorage.getItem('isAuthenticated') == 'true'){
//     if(to.path == '/'){
//       next({ path: 'init' });
//     }
//   }else{
//     next()
//   }
// })

export default router
